package com.edushare.common.dao;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.query.SelectQuery;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.edushare.common.orm.ORMInterface;
import com.edushare.common.util.GradeKeyContainer;
import com.edushare.common.vo.CourseInstances;
import com.edushare.common.vo.Departments;
import com.edushare.common.vo.GradeKey;
import com.edushare.common.vo.Messages;
import com.edushare.common.vo.Universities;

public class GradeKeyDAO extends CayenneBasedDAO {
	public GradeKeyDAO(ORMInterface ormInterface) {
		super(ormInterface);
	}

	private static final Log log = LogFactory.getLog(GradeKeyDAO.class);
	
	@SuppressWarnings("unchecked")
	public GradeKey getKeyByPk(int pkId){
		Expression exp = Expression.fromString("gradeKeyId = $gradeKeyId");
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put("gradeKeyId", pkId);
		SelectQuery q = new SelectQuery(GradeKey.class, exp.expWithParameters(map));
		List<GradeKey> gkList = getDataContext().performQuery(q);
		if(gkList.size()>0)
			return gkList.get(0);
		else
			return null;
	}
}
